<?php
namespace application\index\controller;
use think\Controller;

class CController extends Controller
{
	public $_G;
	
	public function __construct()
	{
		parent::__construct();
		$this->initSiteInfo();
	}
	/**
	 * 初始化站点信息
	 */
	public function initSiteInfo()
	{
        //站点信息
		if (safeCache('siteInfo')) {
			$this->_G['site'] = safeCache('siteInfo');
		} else {
			$site = \application\common\model\Site::get(1);
			$this->_G['site'] = $site->getData();
			safeCache('siteInfo', $this->_G['site'], ['expire'=> 600]);
		}
        //导航导航栏
        if (false && safeCache('navbarInfo')) {
            $this->_G['navbarInfo'] = safeCache('navbarInfo');
        } else {
            $cat = \application\common\model\ArticleCat::All();
            $nav = collection($cat)->toArray();
            foreach ($nav as $key => $value) {
                $nav[$key]['url'] = '/cat/'.$value['catid'];
            }
            $this->_G['navbarInfo'] = $nav;
            safeCache('navbarInfo', $this->_G['navbarInfo'], ['expire'=> 600]);
        }
	}
	/**
     * 插入样式
     * @param string $href  
     */
    public function setCss($href = '')
    {
        $this->_G['css'][]['href'] = $href;
    }
    /**
     * 插入js文件
     * @param string $src  
     */
    public function setJs($src = '')
    {
        $this->_G['js'][]['src'] = $src;
    }
    /**
     * 空操作
     */
    public function _empty($name)
    {
    	echo 'Are You OK?';
    	$this->redirect('ar/index');
    }
}